package org.example.springmybatisdemo.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springmybatisdemo.entity.Dept;
import org.example.springmybatisdemo.entity.User;

import java.util.List;


@Mapper // 作用: 将当前接口生成代理对象，并交给spring管理
public interface DeptMapper {
    //    查询所有用户
//    @Select("select * from users") // 注解 select查询 delete删除
    public List<Dept> deptlist();

    @Delete("delete from dept where id = #{id}")
    public int delete(Integer id); // 返回受影响的行数

//    新增
    @Insert("insert into dept(name, create_time, update_time) values (#{name}, #{createTime}, #{updateTime})")
    void insert(Dept dept);

//    详情接口（数据回显）
    @Select("select * from dept where id = #{id}")
    Dept selectionDeptDetail(Integer id);

    /*
    * 根据id更新mapper
    * */
//    @Update("update dept set name = #{name}, update_time = #{updateTime} where id = #{id}")
    void update(Dept dept);

    @Select("select count(*) from dept")
    Long count();

    @Select("select * from dept limit #{start}, #{pageSize}")
    List<Dept> pagelist(Integer start, Integer pageSize);

    @Select("select * from dept")
    List<Dept> listpluginpage();
}


